<br>
<div class="layui-form" action="">
    <div class="layui-form-item">
      <label class="layui-form-label">书名</label>
      <div class="layui-input-block">
        <input type="text" name="novelName" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">分类</label>
      <div class="layui-input-block">
        <select name="tagId" lay-verify="required">
          <option value=""></option>
          <option value="0">北京</option>
          <option value="1">上海</option>
          <option value="2">广州</option>
          <option value="3">深圳</option>
          <option value="4">杭州</option>
        </select>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">是否完结</label>
      <div class="layui-input-block">
        <input type="radio" name="isDone" value="Y" title="已完结">
        <input type="radio" name="isDone" value="N" title="未完结" checked>
      </div>
    </div>
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">简介</label>
      <div class="layui-input-block">
        <textarea name="intro" placeholder="请输入内容" class="layui-textarea"></textarea>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="createNovel">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
</div>
<script>
    layui.use(['admin','server','form','laytpl'],function(){
        var $ = layui.$;
        var form = layui.form;
        var setter = layui.setter;
        var laytpl = layui.laytpl;
        var server = layui.server;
        var admin = layui.admin;
        form.render();

        form.on('submit(createNovel)',function(data){
            var userInfo = admin.getUserInfo();
            var formValue = data.field;
            var option = {};
            option.data = {
                novelName: formValue.novelName,
                authorId: userInfo.userId,
                tagId: formValue.tagId,
                intro: formValue.intro,
                isDone: formValue.isDone,
            };
            option.url = 'novel/createNovel';
            option.callback = function(successData) {
                console.log(successData);
                if (successData.errorCode == 0) {
                    layer.msg('创建成功');
                }
            };
            server.req(option);
        });
    })
</script>